<template>
    <div class="search-box">
      <el-input
        v-model="searchQuery"
        placeholder="搜索提问..."
        :prefix-icon="Search"
        clearable
        @input="handleSearch"
      />
    </div>
  </template>
  
  <script setup>
  import { ref } from 'vue'
  import { Search } from '@element-plus/icons-vue'
  
  defineOptions({
    name: 'SearchBox'
  })
  
  const searchQuery = ref('')
  
  // 定义要发送的事件
  const emit = defineEmits(['update:search'])
  
  // 搜索处理函数
  const handleSearch = () => {
    emit('update:search', searchQuery.value)
  }
  </script>
  
  <style scoped>
  .search-box {
    flex: 1;
    max-width: 400px;
    margin: 0 20px;
  }
  
  :deep(.el-input__wrapper) {
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
  }
  
  :deep(.el-input__wrapper:hover) {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  }
  
  :deep(.el-input__wrapper.is-focus) {
    box-shadow: 0 3px 12px rgba(64, 158, 255, 0.2) !important;
  }
  
  :deep(.el-input__inner) {
    height: 40px;
    padding: 0 20px;
    font-size: 14px;
  }
  
  :deep(.el-input__inner::placeholder) {
    color: #909399;
  }
  
  :deep(.el-input__suffix) {
    right: 12px;
  }
  
  :deep(.el-input__suffix .el-icon) {
    font-size: 16px;
    color: #909399;
  }
  </style>